package com.boang;

import com.boang.dao.SpuDao;
import com.boang.po.Spu;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/*
  @author: 13813
  @date: 2024/7/23 10:36
*/
public class Dsql {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession(true);
        SpuDao spuDao = sqlSession.getMapper(SpuDao.class);
        Spu sp = new Spu(0, null, "三星 Galaxy S21 5G（SM-G9910）双模5G 骁龙888 超高清专业摄像 120Hz护目屏 游戏手机 8G+128G 墨影灰");
        Spu spu = spuDao.selectSpuByIdAndName(sp);
        System.out.println(spu);
    }
}
